/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package assignment_cp3120.dataObjects;

import assignment_cp3120.DAO.Factory.DAOFactory;
import java.util.Vector;

/**
 *
 * @author Administrator
 */
public class AllLocations {
    private static Vector<DepartureLocation> instance;

    protected AllLocations() {
    }
    public static Vector<DepartureLocation>getInstance() {
        if (instance == null){
            instance = DAOFactory.getDAOFactory().getDepartureLocationDAO().getDepLocations();
        }
        return instance;
    }
    public static String[] getLocationsNames() {
        String[] locNames = new String[AllLocations.getInstance().size()];

        for (int i = 0; i < instance.size(); i++){
            locNames[i] = instance.get(i).getDep_name();
        }
        return locNames;
    }
    public static String getLocationIDFromName(String locationName) {
        String locid = "";

        for (int i = 0; i < instance.size(); i++){
            if(locationName.equals(instance.get(i).getDep_name())){
                locid = instance.get(i).getDep_id();
            }
        }
        return locid;
    }
    public static String getLocationNameFromID(String locationID) {
        String locname = "";

        for (int i = 0; i < instance.size(); i++){
            if(locationID.equals(instance.get(i).getDep_id())){
                locname = instance.get(i).getDep_name();
            }
        }
        return locname;
    }
}
